<?php


function U($mod_con_act,$array=array()){
	$string='';
	$arr=explode('/',$mod_con_act);
	foreach ($array as $k => $v) {
		$string.='&'.$k.'='.$v;
	}
	$path='index.php?c='.$arr[1].'&a='.$arr[2].'&mod='.$arr[0].$string;
	echo $path;
}


//获得子栏目的父级栏目
function getlink($date,$id){
	static $arr=array();
	foreach ($date as $k => $v) {
		if($v['id']==$id){
            $arr[]=$v;
            $arr=getlink($date,$v['pid']);

		}
	}
	return array_reverse($arr,true);
}



//获得子级
function getc($date,$id,$level=0){
	static $arr=array();
	foreach ($date as $k => $v) {
		if($v['pid']==$id){
			$v['lev']=$level;
            $arr[]=$v;
            $arr=getc($date,$v['id'],$level+2);

		}
	}
	return $arr;
}



//获得子id
function getid($date,$id){
	static $arr=array();
	foreach ($date as $k => $v) {
		if($v['pid']==$id){
            $arr[]=$v['id'];
            $arr=getid($date,$v['id']);

		}
	}
	return $arr;
}



//检查图片是否为空,将为空的从数组中移除
function checkimg($file){
	    $arr=array();
        foreach ($file['name'] as $k=>$v) {
                    if(!empty($v)){
                       $arr['name'][$k]=$file['name'][$k];
                       $arr['type'][$k]=$file['type'][$k];
                       $arr['tmp_name'][$k]=$file['tmp_name'][$k];
                       $arr['size'][$k]=$file['size'][$k];
                       $arr['error'][$k]=$file['error'][$k];
                    }

        }
        return $arr;
}